package com.example.controller;

import com.example.entity.MedicalBasicInfo;
import com.example.service.MedicalBasicInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/medicalBasicInfo")
public class MedicalBasicInfoController {

    @Autowired
    private MedicalBasicInfoService medicalBasicInfoService;

    // 创建医疗基本信息
    @PostMapping("/add")
    public String addMedicalBasicInfo(@RequestBody MedicalBasicInfo info) {
        medicalBasicInfoService.addMedicalBasicInfo(info);
        return "医疗基本信息创建成功";
    }

    // 根据ID查询医疗基本信息
    @GetMapping("/get/{id}")
    public MedicalBasicInfo getMedicalBasicInfoById(@PathVariable int id) {
        return medicalBasicInfoService.getMedicalBasicInfoById(id);
    }

    // 查询所有医疗基本信息
    @GetMapping("/all")
    public List<MedicalBasicInfo> getAllMedicalBasicInfo() {
        return medicalBasicInfoService.getAllMedicalBasicInfo();
    }

    // 更新医疗基本信息
    @PutMapping("/update")
    public String updateMedicalBasicInfo(@RequestBody MedicalBasicInfo info) {
        medicalBasicInfoService.updateMedicalBasicInfo(info);
        return "医疗基本信息更新成功";
    }

    // 删除医疗基本信息
    @DeleteMapping("/delete/{id}")
    public String deleteMedicalBasicInfo(@PathVariable int id) {
        medicalBasicInfoService.deleteMedicalBasicInfo(id);
        return "医疗基本信息删除成功";
    }
}
